package com.byxx.deviceMonitoringSys.ui.test;

import javax.swing.JPanel;

import com.byxx.deviceMonitoringSys.test.DeviceMonitor;

import java.awt.BorderLayout;

public class PaMainSinglePanel extends JPanel {
	private PaDeviceMonitorTest paDeviceMonitorTest;
	private PaDeviceMonitorConfigRightTest paDeviceMonitorConfigRightTest;
	private JPanel panel;
	private DeviceMonitor deviceMonitor;

	/**
	 * Create the panel.
	 */
	public PaMainSinglePanel() {
		setLayout(new BorderLayout(0, 0));
		add(getPaDeviceMonitorTest(), BorderLayout.CENTER);
		add(getPaDeviceMonitorConfigRightTest(), BorderLayout.EAST);

	}
	
	public PaMainSinglePanel(DeviceMonitor deviceMonitor) {
		this.deviceMonitor = deviceMonitor;
		setLayout(new BorderLayout(0, 0));
		add(getPaDeviceMonitorTest(), BorderLayout.CENTER);
		add(getPaDeviceMonitorConfigRightTest(), BorderLayout.EAST);

	}

	public PaDeviceMonitorTest getPaDeviceMonitorTest() {
		if(paDeviceMonitorTest==null) {
			paDeviceMonitorTest = new PaDeviceMonitorTest(getDeviceMonitor());
		}
		return paDeviceMonitorTest;
	}

	public void setPaDeviceMonitorTest(PaDeviceMonitorTest paDeviceMonitorTest) {
		this.paDeviceMonitorTest = paDeviceMonitorTest;
	}

	public PaDeviceMonitorConfigRightTest getPaDeviceMonitorConfigRightTest() {
		if(paDeviceMonitorConfigRightTest==null) {
			paDeviceMonitorConfigRightTest = new PaDeviceMonitorConfigRightTest(this);
		}
		return paDeviceMonitorConfigRightTest;
	}

	public void setPaDeviceMonitorConfigRightTest(PaDeviceMonitorConfigRightTest paDeviceMonitorConfigRightTest) {
		this.paDeviceMonitorConfigRightTest = paDeviceMonitorConfigRightTest;
	}

	private JPanel getPanel() {
		if (panel == null) {
			panel = new JPanel();
		}
		return panel;
	}

	public DeviceMonitor getDeviceMonitor() {
		return deviceMonitor;
	}

	public void setDeviceMonitor(DeviceMonitor deviceMonitor) {
		this.deviceMonitor = deviceMonitor;
	}
	
	public void setFloor(String floor) {
		getPaDeviceMonitorTest().setFloor(floor);
	}
}
